package com.liruo.treasureattic.service.user.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.session.Session;
import org.springframework.session.SessionRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @Author:liruo
 * @Date:2022-11-10-20:11:54
 * @Desc
 */
@RestController
@RequestMapping("/inner/user")
@Slf4j
public class ApiUserController {
    @Resource
    private SessionRepository<Session> sessionRepository;
    @GetMapping("/delsession")
    public void delete(HttpSession httpSession){
        log.info("{} {}", httpSession.getLastAccessedTime(), httpSession.getId());
        Session byId = sessionRepository.findById(httpSession.getId());
        log.info("{} ", byId.getLastAccessedTime());
        sessionRepository.deleteById(httpSession.getId());
    }
}
